package com.sky.local_ads.activity;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;

import com.sky.local_ads.adapter.BusinessOfferListAdapter;
import com.sky.local_ads.constants.Constants;
import com.sky.local_ads.store_offers.StoreOfferResponse;
import com.sky.local_ads.store_offers.StoreOffersList;
import com.sky.trueoffers.R;

public class StoreOffersListActivity extends Activity {
	private ListView offersListView;
	private BusinessOfferListAdapter businessOfferListAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_business_offers);
		offersListView=(ListView)findViewById(R.id.businessOffersList);
		getBundleData(this);
		
	}
	
	private void getBundleData(Context context){
		if(getIntent().getExtras()!=null && getIntent().hasExtra(Constants.STORE_OFFER_INTENT)){
			StoreOfferResponse response=(StoreOfferResponse) getIntent().getSerializableExtra(Constants.STORE_OFFER_INTENT);
			if(response!=null){
				List<StoreOffersList> offerList=response.getStoreOffersList();
				businessOfferListAdapter=new BusinessOfferListAdapter(context, offerList);
				offersListView.setAdapter(businessOfferListAdapter);
			}
			
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.store_offers, menu);
		return true;
	}

}
